package com.hxzy.controller.system;

import com.hxzy.common.core.controller.BaseController;
import com.hxzy.common.core.domain.R;
import com.hxzy.common.core.domain.entity.CmsCategory;
import com.hxzy.common.core.domain.entity.NationalStandardIndustry;
import com.hxzy.common.core.domain.entity.SysDictType;
import com.hxzy.common.enums.AckCode;
import com.hxzy.system.service.NationalStandardIndustryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@Api(tags = "国际行业接口")
@RequestMapping(value = "/api")
public class NationalStandardIndustryController extends BaseController {


    @Autowired
    private NationalStandardIndustryService nationalStandardIndustryService;

    @GetMapping(value = "/NationalStandardIndustry/selectAll")
    @ApiOperation(value = "查询所有数据")
    public R listAll (NationalStandardIndustry nation) {
        List<NationalStandardIndustry> list = this.nationalStandardIndustryService.selectAll(nation);
        return R.okHasData(list);
    }
    @ApiOperation(value = "新增栏目")
    @PostMapping(value =  "/system/nation/add")
    public R add(@RequestBody @Valid NationalStandardIndustry industry){
        boolean save = nationalStandardIndustryService.save(industry);
        if(!save){
            return R.okHasData("新增失败");
        }
        return  R.ok();
    }

    /**
     * 获取栏目选择框列表
     */
    @GetMapping("/system/nation/select")
    public R optionselect()
    {
        List<NationalStandardIndustry> dictTypes = nationalStandardIndustryService.selectTitleAll();
        return R.okHasData(dictTypes);
    }


    @GetMapping("/system/nation/selectById/{id}")
    public R selectById(@PathVariable @RequestBody String id)
    {
        NationalStandardIndustry standardIndustry=nationalStandardIndustryService.selectByIds(id);
        if(standardIndustry.getId().equals(id)){
            return R.build(AckCode.IS_EXISTS);
        }

        return R.ok();
    }

}
